﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CMS.BLL;


public partial class Controls_HomePage_ctrLink : System.Web.UI.UserControl
{
    private int nCurrentLanguage = Support.GetCurrentLanguage();
    private int nDefaultLanguage = Support.GetDefaultLanguage(); 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.InitData();
            this.BindDataToLinkDropdown();
        }
    }

    private void InitData()
    {
        lblLink.Text = MultipleLanguage.LINK[nCurrentLanguage-1];
        lblIntro.Text = MultipleLanguage.LINK_WEBSITE[nCurrentLanguage - 1];  
    }
    private void BindDataToLinkDropdown()
    {
        DataTable dtbLanguage = new DataTable();
        Link objAdv = new Link();
        dtbLanguage = objAdv.Search();
        ddlLink.DataSource = dtbLanguage;
        ddlLink.DataValueField = "LinkID";
        ddlLink.DataTextField = "Name";
        ddlLink.DataBind();

    }
    protected void ddlLink_SelectedIndexChanged(object sender, EventArgs e)
    {
        int nID = ConvertData.ConvertToInt(ddlLink.SelectedValue );
        Link objAdv = new Link();
        objAdv.LoadById(nID);
        Response.Redirect("http://" + objAdv.Data.URL   );
    }
}